package com.ljf.tijian.controller;

import com.ljf.tijian.ApiResponse;
import com.ljf.tijian.pojo.Answer;
import com.ljf.tijian.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class QuestionController {

    @Autowired
    QuestionService questionService;

    @RequestMapping("/queryquestion")
    public ApiResponse queryquestion(){
        return questionService.getQuestionaire();
    }

    @RequestMapping("/insertanswer")
    public  ApiResponse insertanswer(@RequestBody List<Answer> list){
        for (Answer answer : list) {
//            System.out.println(answer.getUserId());
            answer.setAnswerDate(new Date());
        }
        return questionService.inputAnswer(list);
    }

}
